﻿using UnityEngine;

[DisallowMultipleComponent]
public class MaterialProperties : MonoBehaviour
{
    static MaterialPropertyBlock block;
    static int baseColorID = Shader.PropertyToID("_BaseColor");
    static int baseMapID = Shader.PropertyToID("_BaseMap");
    [SerializeField]
    public Color baseColor = Color.white;
    public Texture2D baseMap;

    void OnValidate()
    {
        if(block == null)
        {
            block = new MaterialPropertyBlock();
            
        }
        block.SetColor(baseColorID, baseColor);
        GetComponent<Renderer>().SetPropertyBlock(block);
    }
}
